"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    loader.define({
      depend: ['pages/config/config'],
      loaded: function loaded(config, require, exports, module, global) {
        var pageview = {};
        var citySelect = null;
        var personlocation = "";
        var flag;
        this.pageview = {
          init: function init(e) {
            /*-----------------------------下面是必须采取的动态渲染--------------------------------*/
            //控制主干部分的高度
            var h = $("#launch2").height();
            $("#contain2").css("height", h * 0.6);
            $("#launch_launch2").css("margin_top", h * 0.775); //控制每一行的图片位置

            var h2 = $(".con_child2").height();
            $(".pic62").css({
              "height": h2 * 0.4,
              "width": h2 * 0.4,
              "margin_top": h2 * 0.3,
              "margin_left": "2%",
              "float": "left"
            }); // $(".pic").css({"height":h2*0.4,"width":h2*0.4,"margin_top":h2*0.3,"margin_right":"2%","float":"right"});
            // //控制加载地址的位置
            // $("#address").css({"margin_left":"6%","width":"40%"});
            //控制文字垂直居中

            $(".con_child_child2").css("line-height", h2.toString() + "px");
            $(".selected-vals2").css("line-height", h2.toString() + "px", "height", h2 * 0.4, "margin_top", h2 * 0.3); //控制输入框

            $(".inputer2").css({
              "height": h2 * 0.4,
              "width": "40%",
              "margin_top": h2 * 0.3,
              "margin_left": "6%",
              "float": "left",
              "border": "0px",
              "color": "gray",
              "font-weight": "bold"
            }); //动态控制下拉菜单的位置,动态控制css优先级别比静态高
            //注意:bui这里采用的布局本人不太会,其中设置margin值没有继承父元素,也无法再插入div,暂用px进行位移

            $("#uiDropdown2").css({
              "height": h2,
              "width": "60%",
              "position": "relative",
              "float": "right"
            });
            $(".my_box").css({
              "height": "80%",
              "position": "relative",
              "padding": "0px 0px",
              "border": "0px",
              "margin_top": "5px",
              "margin_right": "10px"
            });
            /*-----------------------------上面是必须采取的动态渲染--------------------------------*/

            console.log(h2);
            console.log($(".pic").height());
            var getParams = bui.getPageParams();
            getParams.done(function (result) {
              personlocation = result['personlocation'];
              flag = result['flag'];
            });
            var list = personlocation.trim().split(" "); //console.log(list);
            // 绑定数据

            loader["import"]("js/plugins/citys.js", function () {
              // 设置值
              citySelect = bui.levelselect({
                data: citys,
                title: "所在地区",
                trigger: ".selected-vals2",
                level: 3,
                field: {
                  name: "n",
                  // value: "n",
                  data: ["c", "a"]
                },
                value: list,
                height: 200 // placeholder:personlocation,

              });
            });
            $("#personallocation2").on("click", function () {
              citySelect.show();
            }); //实现下拉列表

            var uiDoropdown = bui.dropdown({
              id: "#uiDropdown2",
              data: [{
                name: "男",
                value: "男"
              }, {
                name: "女",
                value: "女"
              }],
              //设置relative为false,二级菜单继承父层宽度
              relative: false,
              callback: function callback(e) {}
            }); //控制保存按钮,进行保存

            $("#launch_launch2").click(function () {
              //昵称
              var personalname;
              var person_name = $("#personalname2").val();

              if (person_name == "") {
                bui.hint("昵称未填写！");
                return;
              } else personalname = person_name; //性别


              var personalsex;
              var type = $("#type_name12").text();
              if (type == "男") personalsex = type;else if (type == "女") personalsex = type;else {
                bui.hint("性别未选择！");
                return;
              } //年龄

              var personalage;
              var person_age = $("#personalage2").val();

              if (person_age == "") {
                bui.hint("年龄未填写！");
                return;
              } else personalage = person_age; //所在地区


              var personallocation = "";
              var person_location = citySelect.value();

              if (person_location == "") {
                bui.hint("所在地区未选择！");
                return;
              } else {
                for (var key in person_location) {
                  var item = person_location[key];
                  var name = item["name"];
                  personallocation = personallocation + " " + name;
                }
              }

              $("#mine_my_big_part2_div1").attr('value', personallocation);
              console.log(personallocation); //联系方式

              var personalphone;
              var person_phone = $("#personalphone2").val();

              if (person_phone == "") {
                bui.hint("联系方式未填写！");
                return;
              } else personalphone = person_phone; //简介


              var personaldescrible;
              var person_describle = $("#personaldescrible2").val();

              if (person_describle == "") {
                bui.hint("简介未填写！");
                return;
              } else personaldescrible = person_describle;

              var data_temp = {
                name: personalname,
                sex: personalsex,
                age: personalage,
                location: personallocation,
                mobile: personalphone,
                introduction: personaldescrible
              };
              data_temp = JSON.stringify(data_temp);
              bui.ajax({
                url: config.apiurl + "api/v1.0/mysavechange",
                data: data_temp,
                method: "post",
                headers: {
                  'Content-Type': 'application/json'
                }
              }).then(function (res) {
                console.log(res);
              });
              bui.hint({
                content: "<i class='icon-check'></i><br />保存成功",
                position: "center",
                effect: "fadeInDown"
              });
              $("#mine_my_big_part2_div1").text(personalname);
              if (flag.toString() == "1") bui.load({
                url: "pages/success/success"
              });
              if (flag.toString() == "2") bui.back();
            });
            bui.ajax({
              url: config.apiurl + "api/v1.0/mychange",
              data: {},
              method: "post",
              headers: {
                'Content-Type': 'application/json'
              }
            }).done(function (res) {
              console.log(res);
              $("#personalname2").val(res['name']);
              $("#type_name12").text(res['sex']);
              $("#personalage2").val(res['age']); //$("#personallocation").text(res['loc']);
              // citySelect.show(res['loc']);

              $("#personalphone2").val(res['mobile']);
              $("#personaldescrible2").val(res['introduction']);
            }).fail(function (res, status) {
              console.log(status); // status = "timeout" || "error" || "abort", "parsererror"
            }); //回退界面

            $("#back_btn2").click(function () {
              bui.back();
            });
          }
        };
        this.pageview.init();
        return this.pageview;
      }
    });
  }, {}]
}, {}, [1]);